//
//  GetCurrentTime.m
//  TimeShow
//
//  Created by apple on 16/9/20.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "GetCurrentTime.h"

@implementation GetCurrentTime

+(NSString *)currenttime
{
    NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyyMMddHHmmss"];
    NSString *currentTime = [formatter stringFromDate:[NSDate date]];
//    NSString *yearString=[currentTime substringToIndex:4];
//    NSString *monthString=[currentTime substringWithRange:NSMakeRange(4, 2)];
//    if ([[monthString substringToIndex:1]isEqualToString:@"0"]) {
//        monthString=[monthString substringWithRange:NSMakeRange(1, 1)];
//    }
//    NSString *dayStirng=[currentTime substringWithRange:NSMakeRange(6, 2)];
    NSString *hourStirng=[currentTime substringWithRange:NSMakeRange(8, 2)];
    if ([[hourStirng substringToIndex:1]isEqualToString:@"0"]) {
        hourStirng=[hourStirng substringWithRange:NSMakeRange(1, 1)];
    }
    NSString *minuteString=[currentTime substringWithRange:NSMakeRange(10, 2)];
//    NSString *secondString=[currentTime substringWithRange:NSMakeRange(12, 2)];
    NSString *time = [hourStirng stringByAppendingString:[@":" stringByAppendingString:minuteString]];
//    NSString *time=[NSString stringWithFormat:@"当前时间为:%@年%@月%@日%@时%@分%@",yearString,monthString,dayStirng,hourStirng,minuteString,secondString];

    return time;
}

@end
